
//
// 120714 - AH - (Kryddar) Created.
// 121122 - AH - (Midtun *) Constructor no longer accepts Captors.
//

package org.soekrat.engine.captor;

import org.soekrat.conversationevent.AbstractConversationEventSource;
import org.soekrat.engine.captor.event.CaptorEvent;
import org.soekrat.engine.captor.event.CaptorListener;
import org.soekrat.engine.socraton.Bison;
import org.soekrat.environment.Orb;

/**
 * <p>
 *   Base class for
 *   {@link Captor} implementations.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public abstract class AbstractCaptor extends AbstractConversationEventSource 
  implements Captor 
{
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  protected AbstractCaptor(){}
  
  /**
   * <p>
   *   Publishes 
   *   {@link CaptorEvent}s to
   *   {@link CaptorListener}s.
   * </p>
   * @param oname    {@link CaptorEvent#getOntologyName()}.
   * @param captured {@link CaptorEvent#getCaptured()}.
   * @param orb      {@link CaptorEvent#getOrb()}.
   */
  protected final void publish(String oname, Object captured, Orb orb)
  {
    if (captured==null)
    {
      throw new NullPointerException("captured");
    }
    
    CaptorEvent e=new CaptorEvent(this, oname, captured, orb);
    
    publish(e);
  }
  
  /**
   * <p>
   *   Publishes 
   *   {@link CaptorEvent}s to
   *   {@link CaptorListener}s.
   * </p>
   * @param oname    {@link CaptorEvent#getOntologyName()}.
   * @param captured {@link CaptorEvent#getCaptured()}.
   * @param orb      {@link CaptorEvent#getOrb()}.
   * @param bisons   {@link Bison}s.
   */
  protected final void publish(String oname, Object captured, Orb orb,
    Bison... bisons)
  {
    if (captured==null)
    {
      throw new NullPointerException("captured");
    }
    
    CaptorEvent e=new CaptorEvent(this, oname, captured, orb, bisons);
    
    publish(e);
  }
  
}
